package com.ssm.Dao;

import com.ssm.Utils.DBCPUtils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class showmyfavoritesDao {
    public List<Object> showmyfavorites(String username){

        String sql="select * from myfavorites where username=?";
        Object[] objects={username};
        Object[] objects1=null;
        List<Object> objectList=new ArrayList<>();

        ResultSet resultSet = DBCPUtils.executeQuery(sql, objects);
        try {
            while (resultSet.next()){
                String name=resultSet.getString("name");
                String place=resultSet.getString("place");
                String pic=resultSet.getString("picture");
                objects1=new Object[]{name,place,pic};
                objectList.add(objects1);
            }
        }catch (SQLException e){
            e.printStackTrace();
        }finally {
            DBCPUtils.closeAll(resultSet,DBCPUtils.pstmt, DBCPUtils.connection);
        }

        return objectList;
    }

}
